#ifndef PROFILE_H
#define PROFILE_H

#include <QString>
#include <QVariant>
#include <QVector>
#include <QSettings>
#include <QMap>
#include "global.h"
#include "options.h"
#include "favorite.h"

class BBS;
class Board;
class Topic;

class byhh;

/**
    + 保存了每个帐号的通用配置信息，以及负责保存和读取恢复配置
    + BBS的创建及版本由此决定
    + 提供多用户功能 ……？
*/
class Profile: public Favorite, public Options{
    public:
	~Profile();
	Profile(QString newName = "newProfile");
	bool checkLogin();
	void updateCookie(QString &html);
	
	int getType() const;
	BBS * getBBS() const;
	QString getCookies(bool fullFormat = false) const;
	virtual QString getId() const;
	virtual QString getName() const;
	virtual QString getUsername() const;
	virtual QString getPassword() const;	//这个函数涉及敏感信息，也许会被子类覆盖掉
	
	void setType(int type);			//改变配置文件的类型并重新构建配置文件及数据库
	virtual bool setId( QString value);
	virtual bool setName(QString newName);
	virtual bool setUsername(QString newName);
	virtual bool setPassword(QString value);
	
	virtual void save(QSettings &settings);
	virtual void restore(QSettings &settings);
	virtual void erase(QSettings& settings);

    protected:
	int type;
	BBS * bbs;
	QString id;
	QString name;
	QString username;
	QString password;
	QMap<QString , QString> cookies;
};

class baseOnProfile : public QObject{
    protected:
	Profile * profile;
    public:
	baseOnProfile();
	virtual Profile * getProfile() const;
	virtual int setProfile(Profile * newProfile);
};

class supportBBS{
    public:
	enum bbsType {BYHH = 0};
	static int MaxTypeNumber;
	static QString SupportTypes[];
    public:
	static BBS * type2BBS(int type, Profile * profile);
};

#endif
